<?php
class Server {
  public static function submit($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    
    if ($req->__password != '' && (strlen($req->__password) < 6 || strlen($req->__password) > 16)) {
      echo '密码必须6-16位';
      return;
    }
    if ($req->first_name == '' || $req->last_name == '') {
      echo '姓和名都不能为空';
      return;
    }
    
    if ($req->__password != '') {
      $req->password = md5($req->salt . $req->__password);
    }
    $orm->update('pb_ht_customer', $req);
    
    unset($req->__password);
    unset($req->password);
    $_SESSION['user'] = json_encode($req);
    echo json_encode($req);
  }
}
?>